<template>
  <el-dialog
      title="校区修改"
      :visible.sync="auditDialog.visible"
      width="40%">
      <el-form>
        <el-form-item label="学校名称">
          <el-input
          placeholder="请输入学校名称"
          v-model="auditDialog.name">
        </el-input>
        </el-form-item>
        <el-form-item label="学校地址">
          <el-input
          placeholder="请输入学校地址"
          v-model="auditDialog.location">
        </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="auditDialog.visible = false">取 消</el-button>
        <el-button type="primary" @click="auditComfig">确 定</el-button>
      </span>
    </el-dialog>
</template>

<script>
import {
  Vue,
  ref,
  toRefs,
  shallowRef,
  reactive,
  watch,
  watchEffect,
  getCurrentInstance,
  computed,
  defineComponent,
  nextTick,
  inject,
  onMounted,
  onUnmounted
} from 'vue'
import { Message,MessageBox } from 'element-ui'
import store from '@/store'
import {setSchoolEdit} from '@/api/school/school_api.js'
export default {
  name: 'andit',
  setup(props, { emit }) {
   // const emits = defineEmits(['onOk'])
    const Interface = reactive({
      formClick(row){
        query.auditDialog.id = row.id
        query.auditDialog.name = row.name
        query.auditDialog.location = row.location
        query.auditDialog.visible = true
      },
      async auditComfig(){
        if(!query.auditDialog.name){
          return this.$message.error('请输入学校名称')
        }
        if(!query.auditDialog.location){
          return this.$message.error('请输入学校地址')
        }
        let params = {}
        params.schoolId = query.auditDialog.id
        params.location = query.auditDialog.location
        params.name = query.auditDialog.name
       const {code} = await setSchoolEdit(params)
        if(code === 0){
          Message.success('操作成功')
          query.auditDialog.visible = false
          emit('onOk')
        }
      },
    })
    const query = reactive({
      auditDialog:{
        visible:false,
        location:'',
        id:'',
        name:'',
      }
    })
    return {
      ...toRefs(query),
      ...toRefs(Interface)
    }
  }
}
</script>